package com.study.algorithm.datastruct.tree.model;

import java.util.ArrayList;
import java.util.List;

public class Tree {
    private Object data;

    private Integer weight;

    private List<Tree> childrenNode;

    public List<Tree> getChildrenNode() {
        return childrenNode;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public boolean hasChildNode() {
        return childrenNode != null && childrenNode.size() > 0;
    }

    public void addChildNode(Tree childNode) {
        if (childrenNode == null) {
            childrenNode = new ArrayList<>();
        }
        childrenNode.add(childNode);
    }

    public void removeChildNode(Tree childNode) {
        childrenNode.remove(childNode);
    }

    public boolean isContainChildNode(Tree childNode) {
        return childrenNode.contains(childNode);
    }


    public Integer getWeight() {
        return weight;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }
}
